package com.bg.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.bg.entity.Customers;
import com.bg.service.Loginservice;

@Controller
public class LoginController {
	@Autowired
   Loginservice loginservice;
	@RequestMapping("login1")
	public String  login(@RequestParam("email") String email,
			@RequestParam("password") String password,@RequestParam("name") String name,Model model){
		Customers customers=new Customers();
		customers.setEmail(email);
		customers.setPassword(password);
		customers.setName(name);
		if(loginservice.logincheck(customers) != null){
			model.addAttribute("email",email);
			return "main";
		}
	    else{
	    	model.addAttribute("error","账号或密码错误");
	    	return "login1";
	    }
	}


}
